package com.qingcheng.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.business.Ad;
import com.qingcheng.service.business.AdService;
import com.qingcheng.service.goods.CategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {

    @Reference
    private AdService adService;

    @Reference
    private CategoryService categoryService;

    /**
     * 首页广告位查询
     *
     * @param model
     * @return
     */
    @RequestMapping("/index")
    public String index(Model model){

        /**
         * 广告位333333333
         * 32323232
         * 23232323232
         */
        //1：调用服务查询
        List<Ad> adList = adService.findByPostion("web_index_lb");
        //2：封装返回值
        model.addAttribute("adList",adList);


        /**
         * 分类信息
         *
         */
        //1：调用服务查询
        List<Map> list = categoryService.findCategoryTree();
        //2：封装返回值
        model.addAttribute("categoryList",list);
        //3：返回页面
        return "index";
    }


}
